function p = convest(xx,xsol,b)
% function p = convest(xx,b)
% This function estimates the rate of convergence of xx to xsol using
% three subsequent points with the final point being a
% 'b' iterations from the final point.  'b' is used because
% sometimes the final point suffers from roundoff error, etc.
% This approximation is from Hueso et al.

if length(xx(1,:)) > 2
    p = log( norm(xx(:,end-b)-xsol)/ norm(xx(:,end-b-1)-xsol) ) ...
        / log( norm(xx(:,end-b-1)-xsol)/ norm(xx(:,end-b-2)-xsol) );
else
    p = 0;
end